package com.fairytask.ui.item
{
	import com.fairytask.engine.components.BaseItem;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.define.ResConfig;
	
	import flash.geom.Point;
	
	/**
	 * 头像 
	 * @author xujh
	 * 
	 */
	public class HeadItem extends BaseItem
	{
		private var photo	:Clip = new Clip;
		private var lock	:Clip = new Clip;
		
		private var _source	:String;
		private var _isLock	:Boolean = true;
		private var _objID		:Point = null;
		
		public function HeadItem()
		{
			super();
			photo.x = 7;
			photo.y = 7;
			addChild(photo);
			lock.source = ResConfig.pngResPath + "locked.png";
			addChild(lock);
		}
		
		public function set source(val:String):void
		{
			if(val == "")
			{
				return;
			}
			//有图，清除先
			if(_source != "")
			{
				photo.clear();
			}
			_source = val;
			photo.source = val;
			//锁隐藏
			if(_isLock)
			{
				this.isLock = false;
			}
		}
		
		public function get source():String
		{
			return _source;
		}
		
		/**
		 * 是否锁定 
		 * @param val
		 * 
		 */
		public function set isLock(val:Boolean):void
		{
			lock.visible = val;
			_isLock = val;
		}
		
		public function get isLock():Boolean
		{
			return _isLock;
		}
		
		public function set objId(val:Point):void
		{
			_objID = val;
		}
		
		public function get objId():Point
		{
			return _objID;
		}
		
		/**
		 * 删除头像 
		 * 
		 */
		public function clearPhoto():void
		{
			photo.clear();
			_source = "";
			_objID = null;
			data = null;
		}
	}
}